// 蜂窝蜜造平台生成代码，如手工更改，请添加到 .beeignore 忽略生成

package com.fowo.api.documentCirculation.entity;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fowo.api.common.annotaion.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.util.Arrays;

import lombok.Data;
import org.springframework.util.StringUtils;

/**
 * 数据事务分支实体
 * @author yl_ls
 */
@Data
@TableName(value = "data_task_branch", autoResultMap = true)
@Schema(title = "数据事务分支")
public class DataTaskBranch implements Serializable {

  /**
   * 所属数据事务
   */
  @TableField(value = "`parent_id`")
  @JoinField(DataTask.class)
  @Schema(title = "所属数据事务")
  private Long parentId;

  /**
   * 编号
   */
  @TableField(value = "`id`")
  @TableId(type = IdType.ASSIGN_ID)
  @Schema(title = "编号")
  private Long id;

  /**
   * 创建时间
   */
  @TableField(value = "`create_time`")
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  @Schema(title = "创建时间")
  private java.util.Date createTime;

  /**
   * 创建人
   */
  @TableField(value = "`create_user`")
  @Schema(title = "创建人")
  private Long createUser;

  /**
   * 更新时间
   */
  @TableField(value = "`last_update_time`")
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  @Schema(title = "更新时间")
  private java.util.Date lastUpdateTime;

  /**
   * 更新人
   */
  @TableField(value = "`last_update_user`")
  @Schema(title = "更新人")
  private Long lastUpdateUser;

  /**
   * 删除标记
   */
  @TableField(value = "`del_flag`")
  @TableLogic
  @Schema(title = "删除标记")
  private Boolean delFlag;

  /**
   * 类型
   */
  @TableField(value = "`type`")
  @Schema(title = "类型")
  private String type;

  /**
   * 源表
   */
  @TableField(value = "`from_table`")
  @Schema(title = "源表")
  private String fromTable;

  /**
   * 源对象名
   */
  @TableField(value = "from_object_name")
  @Schema(title = "源对象名")
  private String fromObjectName;

  /**
   * 源主子表关联
   */
  @TableField(value="from_association")
  @Schema(title = "源主子表关联")
  private String fromAssociation;

  /**
   * 目标表
   */
  @TableField(value = "`to_table`")
  @Schema(title = "目标表")
  private String toTable;

  /**
   * 目标对象名
   */
  @Schema(title = "目标对象名")
  @TableField(value = "to_object_name")
  private String toObjectName;

  /**
   * 源主子表关联
   */
  @TableField(value="to_association")
  @Schema(title = "目标主子表关联")
  private String toAssociation;

  /**
   * 源表状态字段
   */
  @TableField(value = "`from_table_status_field`")
  @Schema(title = "源表状态字段")
  private String fromTableStatusField;

  /**
   * 中间值
   */
  @TableField(value = "`median`")
  @Schema(title = "中间值")
  private String median;

  /**
   * 完成值
   */
  @TableField(value = "`completion_value`")
  @Schema(title = "完成值")
  private String completionValue;

  /**
   * 源表检测字段
   */
  @TableField(value = "`from_table_detection_field`")
  @Schema(title = "源表检测字段")
  private String fromTableDetectionField;

  /**
   * 源表钩稽字段
   */
  @TableField(value = "`from_table_cross_check_fields`")
  @Schema(title = "源表钩稽字段")
  private String fromTableCrossCheckFields;

  /**
   * 源表钩稽数量回退字段，当源表钩稽字段值为空时，从这个字段复制数量
   */
  @TableField(value = "`from_table_cross_back_fields`")
  @Schema(title = "源表回退字段")
  private String fromTableCrossBackFields;

  /**
   * 目标表钩稽数（逗号分隔多个字段）
   */
  @TableField(value = "`to_table_cross_check_fields`")
  @Schema(title = "目标表钩稽数")
  private String toTableCrossCheckFields;

  /**
   * 获取首个目标表钩稽数
   */
  public String getFirstToTableCrossCheckFields() {
    if (StringUtils.hasText(toTableCrossCheckFields)) {
      return toTableCrossCheckFields.trim().split("\\s*,\\s*")[0];
    }
    return null;
  }

  /**
   * 获取其它目标表钩稽数
   */
  public String[] getOtherToTableCrossCheckFields() {
    if (StringUtils.hasText(toTableCrossCheckFields)) {
      String[] split = toTableCrossCheckFields.trim().split("\\s*,\\s*");
      if (split.length > 1) {
        return Arrays.copyOfRange(split, 1, split.length);
      }
    }
    return new String[0];
  }

  /**
   * 源表钩稽累积字段
   */
  @TableField(value = "`from_table_cumulative_fields`")
  @Schema(title = "源表钩稽累积字段")
  private String fromTableCumulativeFields;

  /**
   * 目标表ID列
   */
  @TableField(value = "`to_table_id_column`")
  @Schema(title = "目标表ID列")
  private String toTableIdColumn;

    /**
   * 目标表ID列
   */
  @TableField(value = "`to_table_bd_id_column`")
  @Schema(title = "目标表体ID列")
  private String toTableBdIdColumn;

  /**
   * 钩稽标识
   */
  @TableField(value = "`cross_check_id`")
  @Schema(title = "钩稽标识")
  private Boolean crossCheckId;

  @TableField(value = "`unique_mappings`")
  @Schema(title = "唯一数据字段对应")
  private String uniqueMappings;

  @TableField(value = "`support_negative`")
  @Schema(title = "可钩稽负数")
  private Boolean supportNegative;

  @TableField(value = "`support_beyond`")
  @Schema(title = "可超出源数量")
  private Boolean supportBeyond;

  @TableField(value = "`is_negative`")
  @Schema(title = "红冲支持")
  private Boolean isNegative;

  @TableField(value = "`is_hc_cross_checking`")
  @Schema(title = "红冲勾稽")
  private Boolean isHCCrossChecking;
}
